<?php
session_start();
ob_start('ob_gzhandler');
include 'config.php';

$dm = $_GET['danhmuc'];
$dm = explode('/',$dm);
$danhmuc = $dm[0];
if($dm[1]=='') $page = 1; else $page = $dm[1];
$dt = $_GET['detail'];
$idMenu = $tc->id_menu($danhmuc);
$detail = $tc->id_info($dt);
/*if($danhmuc!='thu-vien') $detail = $tc->id_info($dt);
else $detail = $tc->id_menu($dt);*/
$tc->html($domain);
if(@$detail){
	$qr = $tc->detail($detail);
	$detail = mysql_fetch_array($qr);
    $rewrite = str_replace('-',' ',$detail['name_rewrite']);
    $title = "{$detail['name']}, {$rewrite}";
	($detail['url_hinh']!='') ? $image='/'.url_hinh_info_thumbs.$detail['url_hinh'] : $image=url_hinh_default;
	$seo = $tc->seo($domain,$title,$detail['description'],$detail['metaKeyword'],$image,$_SERVER['REQUEST_URI']);
    
    ob_start();
    $qr = $tc->menu_one($idMenu);
	$menu = mysql_fetch_array($qr);
	switch($menu['type_id']){
        case 2 : include_once('blocks/viewpost_thongtin.php'); break;
        case 3 : include_once('blocks/viewpost_xeco.php'); break;
        case 4 : include_once('blocks/viewpost_thongtin.php'); break;
        case 5 : include_once('blocks/viewpost_thongtin.php'); break;
        //case 6 : include_once('blocks/viewpost_video.php'); break;
        default : header("location: index.html");
    }
	$include = ob_get_clean();
}else if(@$danhmuc){
    $qr = $tc->menu_one($idMenu);
	$menu = mysql_fetch_array($qr);
    $rewrite = str_replace('-',' ',$menu['name_rewrite']);
    $title = "{$menu['title']}, {$rewrite}";
	($menu['url_hinh']!='') ? $image=$menu['url_hinh'] : $image=url_hinh_default;
	$seo = $tc->seo($domain,$title,$menu['metaDescription'],$menu['metaKeyword'],$image,$menu['url']);
    
    ob_start();
    switch($menu['type_id']){
        case 2 : include_once('blocks/catalog_thongtin.php'); break;
        case 3 : include_once('blocks/catalog_xeco.php'); break;
        case 4 : include_once('blocks/catalog_traodoi.php'); break;
        case 5 : include_once('blocks/catalog_hoidap.php'); break;
        case 6 : include_once('blocks/catalog_video.php'); break;
        case 7 : include_once('blocks/catalog_contact.php'); break;
        default : header("location: index.html");
    }
	$include = ob_get_clean();
}else{
	$home = $tc->menu_one(1);
	$row_home = mysql_fetch_array($home);
	$title = $row_config['title'];
	$description = $row_home['metaDescription'];
	$keywords = $row_home['metaKeyword'];
	$image = '/images/logo1.png';
	$url = 'index.html';
	$tc->seo($domain,$title,$description,$keywords,$image,$url);
	ob_start();
	$include = include_once('blocks/home.php');
	$include = ob_get_clean();
}

$tc->css($css);
?>
<div id="popup"></div>
<!--<div id="background">-->
<div style="background:url(images/bg-transparent.png); margin:0; padding:0">
<div id="wrapper">
	<?php include_once('blocks/menu.php');?>
	<div id="slider">
    	<div style="width:120px; margin:40px auto 20px auto"><a href="index.html"><img src="images/logo1.png" alt="" /></a></div>
        <div style="width:100%; text-align:center">
		<?php
		if(!@$idMenu) $idMenu=1;
        $slider = mysql_query("SELECT name,url_hinh,link FROM slider_banner WHERE `delete`=0 AND status=1 AND position_id=1 AND menu_id LIKE '%,{$idMenu},%'");
		while($row_slider = mysql_fetch_array($slider)){
			echo '<a href="'.$row_slider['link'].'"><img src="upload/images/slider/'.$row_slider['url_hinh'].'" alt="'.$row_slider['name'].'" /></a>';
		}
		?></div>
    </div>
    <div style="clear:both; height:30px"></div>
    <div style="width:100%; height:10px; background:url(images/content1.png)"></div>
    <div id="content">
		<div style="clear:both"><?php if(!@$_GET['p']) echo $include; else include_once('blocks/muaban.php');?></div>
    	<div style="clear:both; height:40px"></div>
    </div>
	<div style="clear:both"></div>
</div>
<div style="width:100%; clear:both; background-color:#474747">
	<div style="width:1000px; margin:0  auto">
    	<div style="width:100%; height:30px; text-align:center; background:url(images/content2.png)">
        	<?php echo '<a href="'.$_SERVER['REQUEST_URI'].'#" id="top">[ Đầu trang ]</a> &nbsp; | &nbsp; <a href="javascript:window.history.go(-1)">[ Trang trước ]</a>'?>
        </div>
        <table width="100%" border="0" cellpadding="0" cellspacing="0" style="color:#FFF; padding:10px 0">
        	<?php echo '<tr><td><p style="line-height:18px">'.$row_config['contact'].'</p></td><td align="right">'.$row_config['footer'].'</td></tr>' ?>
        </table>
    </div>
</div>
</div>
<div id="facebook" style="position:fixed; top:30%; z-index:100; width:54px; padding:4px 3px 4px 4px; background-color:#E0DBC7; border:solid 1px #999">
<a href="http://www.facebook.com/clbhongcuong" target="_blank"><img style="margin-bottom:3px" src="images/logo-face.jpg" alt="logo facebook" /></a>
<div class="fb-like" data-href="http://www.facebook.com/clbhongcuong" data-send="true" data-layout="box_count" data-width="50" data-show-faces="true"></div></div>
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/vi_VN/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script type="text/javascript" src="script/multizoom.js"></script>
<script type="text/javascript" src="website.js"></script>
<script src="library/scroll/jquery.mCustomScrollbar.concat.min.js"></script>
<script type="text/javascript">
	(function($){
		$(window).load(function(){
			$("#content_1,#content_2").mCustomScrollbar({
				autoHideScrollbar:false,
				theme:"light-thin"
			});
		});
	})(jQuery);
</script>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-39821711-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</body>
</html>